home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / mfb / RCS / mfbgetsp.c,v < prev    next >
Encoding:
Text File  |  1990-02-15  |  4.4 KB  |  166 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     90.02.14.19.58.07;  author tve;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @Original X11R4 distribution
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
  27. /***********************************************************
  28. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  29. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  30.  
  31.                         All Rights Reserved
  32.  
  33. Permission to use, copy, modify, and distribute this software and its 
  34. documentation for any purpose and without fee is hereby granted, 
  35. provided that the above copyright notice appear in all copies and that
  36. both that copyright notice and this permission notice appear in 
  37. supporting documentation, and that the names of Digital or MIT not be
  38. used in advertising or publicity pertaining to distribution of the
  39. software without specific, written prior permission.  
  40.  
  41. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  42. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  43. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  44. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  45. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  46. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  47. SOFTWARE.
  48.  
  49. ******************************************************************/
  50. /* $XConsortium: mfbgetsp.c,v 5.5 89/09/14 16:26:46 rws Exp $ */
  51. #include "X.h"
  52. #include "Xmd.h"
  53.  
  54. #include "misc.h"
  55. #include "region.h"
  56. #include "gc.h"
  57. #include "windowstr.h"
  58. #include "pixmapstr.h"
  59. #include "scrnintstr.h"
  60.  
  61. #include "mfb.h"
  62. #include "maskbits.h"
  63.  
  64. #include "servermd.h"
  65.  
  66. /* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
  67.  * and continuing for pwidth[i] bits
  68.  * Each scanline returned will be server scanline padded, i.e., it will come
  69.  * out to an integral number of words.
  70.  */
  71. /*ARGSUSED*/
  72. void
  73. mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
  74.     DrawablePtr        pDrawable;    /* drawable from which to get bits */
  75.     int            wMax;        /* largest value of all *pwidths */
  76.     register DDXPointPtr ppt;        /* points to start copying from */
  77.     int            *pwidth;    /* list of number of bits to copy */
  78.     int            nspans;        /* number of scanlines to copy */
  79.     unsigned int    *pdstStart;    /* where to put the bits */
  80. {
  81.     register unsigned int    *pdst;    /* where to put the bits */
  82.     register unsigned int    *psrc;    /* where to get the bits */
  83.     register unsigned int    tmpSrc;    /* scratch buffer for bits */
  84.     unsigned int        *psrcBase;    /* start of src bitmap */
  85.     int            widthSrc;    /* width of pixmap in bytes */
  86.     register DDXPointPtr pptLast;    /* one past last point to get */
  87.     int             xEnd;        /* last pixel to copy from */
  88.     register int    nstart; 
  89.     int             nend; 
  90.     int             srcStartOver; 
  91.     int             startmask, endmask, nlMiddle, nl, srcBit;
  92.     int            w;
  93.   
  94.     pptLast = ppt + nspans;
  95.  
  96.     if (pDrawable->type == DRAWABLE_WINDOW)
  97.     {
  98.     psrcBase = (unsigned int *)
  99.         (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devPrivate.ptr);
  100.     widthSrc = (int)
  101.            ((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind;
  102.     }
  103.     else
  104.     {
  105.     psrcBase = (unsigned int *)(((PixmapPtr)pDrawable)->devPrivate.ptr);
  106.     widthSrc = (int)(((PixmapPtr)pDrawable)->devKind);
  107.     }
  108.     pdst = pdstStart;
  109.  
  110.     while(ppt < pptLast)
  111.     {
  112.     xEnd = min(ppt->x + *pwidth, widthSrc << 3);
  113.     pwidth++;
  114.     psrc = psrcBase + (ppt->y * (widthSrc >> 2)) + (ppt->x >> 5); 
  115.     w = xEnd - ppt->x;
  116.     srcBit = ppt->x & 0x1f;
  117.  
  118.     if (srcBit + w <= 32) 
  119.     { 
  120.         getandputbits0(psrc, srcBit, w, pdst);
  121.         pdst++;
  122.     } 
  123.     else 
  124.     { 
  125.  
  126.         maskbits(ppt->x, w, startmask, endmask, nlMiddle);
  127.         if (startmask) 
  128.         nstart = 32 - srcBit; 
  129.         else 
  130.         nstart = 0; 
  131.         if (endmask) 
  132.         nend = xEnd & 0x1f; 
  133.         srcStartOver = srcBit + nstart > 31;
  134.         if (startmask) 
  135.         { 
  136.         getandputbits0(psrc, srcBit, nstart, pdst);
  137.         if(srcStartOver)
  138.             psrc++;
  139.         } 
  140.         nl = nlMiddle; 
  141. #ifdef FASTPUTBITS
  142.         Duff(nl, putbits(*psrc, nstart, 32, pdst); psrc++; pdst++;);
  143. #else
  144.         while (nl--) 
  145.         { 
  146.         tmpSrc = *psrc;
  147.         putbits(tmpSrc, nstart, 32, pdst);
  148.         psrc++;
  149.         pdst++;
  150.         } 
  151. #endif
  152.         if (endmask) 
  153.         { 
  154.         putbits(*psrc, nstart, nend, pdst);
  155.         if(nstart + nend > 32)
  156.             pdst++;
  157.         } 
  158.         if (startmask || endmask)
  159.         pdst++; 
  160.     } 
  161.         ppt++;
  162.     }
  163. }
  164.  
  165. @
  166.